﻿using System;
using System.Collections.Generic;
using System.Text;
using SharpSvn;

namespace TSVNAddin.SVN
{
	public class SVNClientAdapter
	{
		public virtual string GetRepositoryPath(string fileName)
		{
			using (SvnClient client = new SvnClient())
			{
				SvnInfoEventArgs info;
				SvnTarget svnTarget = SvnTarget.FromString(fileName);
				client.GetInfo(svnTarget, out info);

				string filePath = info.Path;
				Uri repositoryUri = info.RepositoryRoot;
				Uri fileUri = info.Uri;

				RepositoryPathBuilder pathBuilder = new RepositoryPathBuilder();
				string repositoryPath = pathBuilder.BuildPath(filePath, repositoryUri, fileUri);

				return repositoryPath;
			}
		}
	}
}
